package com.starview.star.compiler.sources;

import com.starview.platform.data.IFunction;
import com.starview.platform.data.type.IType;
import com.starview.star.compiler.cafe.compile.Utils;
import com.starview.star.operators.ICafeBuiltin;

public final class NestedBuiltin implements ICafeBuiltin
{
  private final String name;
  private final IType type;
  private final Class<? extends IFunction> klass;

  public NestedBuiltin(String name, IType type, Class<? extends IFunction> klass)
  {
    this.name = name;
    this.type = type;
    this.klass = klass;
  }

  @Override
  public IType getType()
  {
    return type;
  }

  @Override
  public String getName()
  {
    return name;
  }

  @Override
  public String getJavaName()
  {
    return Utils.javaIdentifierOf(name);
  }

  @Override
  public String getJavaType()
  {
    return Utils.javaInternalClassName(klass);
  }

  @Override
  public String getJavaSig()
  {
    String sig = Utils.javaTypeSig(klass);
    return sig;
  }

  @Override
  public String getJavaInvokeName()
  {
    return "enter";
  }

  @Override
  public String getJavaInvokeSignature()
  {
    return Utils.javaInvokeSig(klass, "enter");
  }

  @Override
  public boolean isStatic()
  {
    return false;
  }

  @Override
  public Class<?> getImplClass()
  {
    return klass;
  }
}